// pages/app/user/userInfo/userInfo.js
const app = getApp();
var host = app.globalData.host;
var utils = app.globalData.utils;
var self = null;

Page({
  data: {
    themeColor: '',
    themeColor2: '',
    themeColor3: '',
    defaultColor: '',
    borderColor: '',
    info: {}
  },
  onLoad: function (options) {
    self = this;
    self.getStyle();
    self.init();
  },
  getStyle() {
    self.setData({
      themeColor: app.globalData.themeColor,
      themeColor2: app.globalData.themeColor2,
      themeColor3: app.globalData.themeColor3,
      defaultColor: app.globalData.defaultColor,
      borderColor: app.globalData.borderColor
    })
  },
  init() {
    var userInfo = app.globalData.userInfo;

    self.setData({
      info: userInfo
    })

    if (userInfo.companyId) {
      var url = host + '/lx/mini/user/companyInfo';
      var params = {
        id: userInfo.companyId
      };
      var success = function (res) {
        var info = self.data.info;
        info['company'] = res.info.name;
        self.setData({
          info: info
        })
      }
      var fail = function (res) {
        console.log(res);
      };
      var complete = function () { };
      utils.request(url, params, success, fail, complete);
    }
  },
  goEdit(e) {
    wx.navigateTo({
      url: '/pages/app/user/signUp/signUp?editMode=1'
    })
  }
})